package com.jming.jike.enums;

import com.jming.jike.common.BusinessException;

/**
 * 通用状态枚举
 *
 * @author jinming.zhang
 * @version 0.0.1
 * @date 2022/04/22
 */
public enum StatusEnum {

    /**
     * 启用(售)状态
     */
    START_STATUS(1, "启"),

    /**
     * 停用(售)状态
     */
    STOP_STATUS(0, "禁");

    private final Integer code;
    private final String desc;

    StatusEnum(Integer code, String desc) {

        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 检查状态
     *
     * @param code
     * @Author jinming.zhang
     * @Date 2022/4/22
     */
    public static void checkStatus(Integer code) {

        for (StatusEnum statusEnum : StatusEnum.values()) {
            if (statusEnum.code.equals(code)) {
                return;
            }
        }

        throw new BusinessException("状态不正确!");

    }
}
